<template>
  <div class="container">
    <el-button @click="orderPtinrDialogVisible = true" type="primary"
      >订单打印</el-button
    >
    <div style="margin-bottom: 10px; float: right">
      <el-button type="primary" @click="cancel">取消</el-button>
      <el-button type="primary" @click="save">保存</el-button>
      <el-button type="primary" @click="getData">刷新</el-button>
    </div>

    <div id="orderPrint">
      <div style="line-height: 1.5; margin-bottom: 20px" v-if="orderInfo">
        <h3 class="t_a">内部订货单</h3>
        <div>{{ orderInfo.custCompany }}</div>
        <div>客户订单号：{{ orderInfo.custOrderNo }}</div>
        <div class="d-flex">
          <div class="w_25">客户：{{ orderInfo.customer }}</div>
          <div class="w_25">伸线材质：{{ orderInfo.material }}</div>
          <div class="w_25">内部订单号：{{ orderInfo.orderNo }}</div>
        </div>
        <div class="d-flex">
          <div class="w_25">订单日期：{{ orderInfo.orderDate }}</div>
          <div class="w_25">物料齐备日期：{{ orderInfo.readyDate }}</div>
          <div class="w_25">要求交期：{{ orderInfo.requireDate }}</div>
          <div class="w_25 d-flex">
            回复日期：{{ orderInfo.replyDate }}
            <i
              v-if="isPlan && !showEditDate"
              class="el-icon-edit"
              style="color: #409eff; cursor: pointer"
              @click="setReplyDate"
            ></i>
            <div class="d-flex" v-show="showEditDate">
              <el-date-picker
                class="replyDate"
                v-model="replyDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              >
              </el-date-picker>
              <el-button size="mini" type="primary" @click="saveReplyDate"
                >保存</el-button
              >
            </div>
          </div>
        </div>
        <div class="d-flex">
          <div style="width: 76px">客户要求：</div>
          <div>{{ orderInfo.requirement }}</div>
        </div>
        <div class="d-flex">
          <div style="width: 100px">
            <span>内部特殊要求：</span>
            <span style="display: inline; position: absolute">
              <span v-if="!showEditRequirement2">
                {{ orderInfo.requirement2 }}</span
              >
              <i
                v-if="isQC && !showEditRequirement2"
                class="el-icon-edit"
                style="color: #409eff; cursor: pointer"
                @click="setReplyRequirement2"
              ></i>

              <div v-show="showEditRequirement2">
                <el-input
                  v-model="requirement2"
                  style="width: 800px !important"
                />
                <el-button size="mini" type="primary" @click="saveRequirement2"
                  >保存</el-button
                >
              </div>
            </span>
          </div>
        </div>
      </div>

      <!-- 此处是订单打印 -->
      <el-dialog :visible.sync="orderPtinrDialogVisible" width="1147px">
        <el-button @click="orderPtinrDialogVisible = false">取消打印</el-button>
        <el-button v-print="'#orderPrint2'" type="primary">确定打印</el-button>
        <div id="orderPrint2">
          <div style="line-height: 1.5; margin-bottom: 20px">
            <h3 class="t_a">内部订货单</h3>
            <div>{{ orderInfo.custCompany }}</div>
            <div>客户订单号：{{ orderInfo.custOrderNo }}</div>
            <div class="d-flex">
              <div class="w_25">客户：{{ orderInfo.customer }}</div>
              <div class="w_25">伸线材质：{{ orderInfo.material }}</div>
              <div class="w_25">内部订单号：{{ orderInfo.orderNo }}</div>
            </div>
            <div class="d-flex">
              <div class="w_25">订单日期：{{ orderInfo.orderDate }}</div>
              <div class="w_25">物料齐备日期：{{ orderInfo.readyDate }}</div>
              <div class="w_25">要求交期：{{ orderInfo.requireDate }}</div>
              <div class="w_25 d-flex">
                回复日期：{{ orderInfo.replyDate }}
                <i
                  v-if="isPlan && !showEditDate"
                  class="el-icon-edit"
                  style="color: #409eff; cursor: pointer"
                  @click="setReplyDate"
                ></i>
                <div class="d-flex" v-show="showEditDate">
                  <el-date-picker
                    class="replyDate"
                    v-model="replyDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                  <el-button size="mini" type="primary" @click="saveReplyDate"
                    >保存</el-button
                  >
                </div>
              </div>
            </div>
            <div class="d-flex">
              <div style="width: 95px">客户要求：</div>
              <div>{{ orderInfo.requirement }}</div>
            </div>
          </div>
          <el-table
            :data="orderItem"
            border
            max-height="600"
            :header-row-style="rowHeader"
            style="font-size: 14px; font-weight: 600"
          >
            <el-table-column
              prop="seque"
              label="序号"
              width="36"
              align="center"
              fixed="left"
            ></el-table-column>
            <el-table-column
              label="客户品名"
              align="center"
              prop="custProcuctName"
              width="54"
            >
              <template slot-scope="scope">
                {{ scope.row.custProcuctName }}
              </template>
            </el-table-column>

            <el-table-column
              prop="export"
              label="出口"
              align="center"
              fixed="left"
              width="40"
            >
              <template slot-scope="scope">
                {{ scope.row.export }}
              </template>
            </el-table-column>
            <el-table-column
              prop="excessive"
              label="类型备注"
              align="center"
              width="100"
            >
              <template slot-scope="scope">
                {{ scope.row.excessive }}
              </template>
            </el-table-column>

            <el-table-column
              prop="specs"
              label="规格"
              align="center"
              width="78"
              fixed="left"
              sortable="custom"
            >
              <template slot-scope="scope"> {{ scope.row.specs }} </template>
            </el-table-column>
            <el-table-column prop="unit" label="单位" align="center" width="36">
              <template slot-scope="scope">
                {{ scope.row.unit }}
              </template>
            </el-table-column>

            <el-table-column
              prop="amount"
              label="数量"
              align="center"
              fixed="left"
              width="40"
            >
              <template slot-scope="scope">
                {{ scope.row.amount }}
              </template>
            </el-table-column>

            <el-table-column
              prop="toleranceUp"
              label="公差下限"
              align="center"
              width="110"
              fixed="left"
            >
              <template slot-scope="scope">
                {{ scope.row.toleranceDown }}
              </template>
            </el-table-column>
            <el-table-column
              prop="toleranceUp"
              label="公差上限"
              align="center"
              width="110"
              fixed="left"
            >
              <template slot-scope="scope">
                {{ scope.row.toleranceUp }}
              </template>
            </el-table-column>

            <el-table-column
              prop="shellSize"
              label="外壳尺寸"
              width="65"
              align="center"
              fixed="left"
            >
              <template slot-scope="scope">
                {{ scope.row.shellSize }}
              </template>
            </el-table-column>

            <el-table-column
              prop="itemNo"
              label="指定料号"
              align="center"
              fixed="left"
              width="60"
            >
              <template slot-scope="scope">
                {{ scope.row.itemNo }}
              </template>
            </el-table-column>

            <el-table-column
              prop="compressDown"
              label="压缩角公差下限"
              align="center"
              width="76"
            >
              <template slot-scope="scope">
                {{ scope.row.compressDown }}
              </template>
            </el-table-column>

            <el-table-column
              prop="compressDown"
              label="压缩角公差上限"
              align="center"
              width="76"
            >
              <template slot-scope="scope">
                {{ scope.row.compressUp }}
              </template>
            </el-table-column>

            <el-table-column
              prop="dingjingDown"
              label="定径公差下限"
              align="center"
              width="74"
            >
              <template slot-scope="scope">
                {{ scope.row.dingjingDown }}
              </template>
            </el-table-column>

            <el-table-column
              prop="dingjingDown"
              label="定径公差上限"
              align="center"
              width="74"
            >
              <template slot-scope="scope">
                {{ scope.row.dingjingUp }}
              </template>
            </el-table-column>

            <el-table-column
              prop="roughSupplier"
              label="供应商代码"
              align="center"
              width="80"
            >
              <template slot-scope="scope">
                {{ scope.row.roughSupplier }}
              </template>
            </el-table-column>
            <el-table-column
              prop="roughItemNo"
              label="料号"
              align="center"
              width="50"
            >
              <template slot-scope="scope">
                {{ scope.row.roughItemNo }}
              </template>
            </el-table-column>

            <el-table-column
              prop="compressDown2"
              label="压缩角公差下限2"
              align="center"
              width="76"
            >
              <template slot-scope="scope">
                {{ scope.row.compressDown2 }}
              </template>
            </el-table-column>

            <el-table-column
              prop="compressUp2"
              label="压缩角公差上限2"
              align="center"
              width="76"
            >
              <template slot-scope="scope">
                {{ scope.row.compressUp2 }}
              </template>
            </el-table-column>

            <el-table-column
              prop="dingjingDown2"
              label="定径公差下限2"
              align="center"
              width="74"
            >
              <template slot-scope="scope">
                {{ scope.row.dingjingDown2 }}
              </template>
            </el-table-column>

            <el-table-column
              prop="dingjingUp2"
              label="定径公差上限2"
              align="center"
              width="74"
            >
              <template slot-scope="scope">
                {{ scope.row.dingjingUp2 }}
              </template>
            </el-table-column>

            <el-table-column
              prop="custNo"
              label="客户代码"
              align="center"
              width="56"
            >
              <template slot-scope="scope">
                {{ scope.row.custNo }}
              </template>
            </el-table-column>
            <el-table-column
              prop="numberStart"
              label="模具编号"
              width="180"
              align="center"
            >
              <template slot-scope="scope">
                {{ scope.row.numberStart }}~ {{ scope.row.numberEnd }}
              </template>
            </el-table-column>
          </el-table>

          <div class="mt_10 mb_10">注：{{ orderInfo.remark }}</div>
          <div class="d-flex font-bold">
            <div class="w_20">生产课：{{ orderInfo.production }}</div>
            <div class="w_20">品管：{{ orderInfo.qc }}</div>
            <div class="w_20">计划：{{ orderInfo.plan }}</div>
            <div class="w_20">技术：{{ orderInfo.technology }}</div>
            <div class="w_20">业务：{{ orderInfo.business }}</div>
          </div>
          <div class="d-flex mb_20 font-bold">
            <div class="w_20">日期：{{ orderInfo.productionDate }}</div>
            <div class="w_20">日期：{{ orderInfo.qcDate }}</div>
            <div class="w_20">日期：{{ orderInfo.planDate }}</div>
            <div class="w_20">日期：{{ orderInfo.technologyDate }}</div>
            <div class="w_20">日期：{{ orderInfo.businessDate }}</div>
          </div>
        </div>
      </el-dialog>

      <el-table
        :data="orderItem"
        border
        show-summary
        max-height="600"
        style="font-size: 14px"
        :summary-method="getSummaries"
        @cell-dblclick="cellDbClick"
        @sort-change="sortChange"
      >
        <el-table-column
          prop="seque"
          label="序号"
          width="40"
          align="center"
          fixed="left"
        ></el-table-column>

        <el-table-column
          label="存货代码"
          align="center"
          width="100"
          fixed="left"
          prop="productName"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.productNameIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.productName"
              @blur="blurEvent('productNameIsEdit')"
              @input="inputEvent($event, 'productName', 'productNameIsEdit')"
              @focus="focusEvent(scope)"
              placeholder="请输入"
            ></el-input>
            <span v-else>{{ scope.row.productName }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="客户品名"
          align="center"
          fixed="left"
          prop="custProcuctName"
          width="70"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.custProcuctNameIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.custProcuctName"
              @blur="blurEvent('custProcuctNameIsEdit')"
              @input="
                inputEvent($event, 'custProcuctName', 'custProcuctNameIsEdit')
              "
              @focus="focusEvent(scope)"
              placeholder="请输入"
            ></el-input>
            <span v-else>{{ scope.row.custProcuctName }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="amount"
          label="数量"
          align="center"
          fixed="left"
          width="60"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.amountIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.amount"
              placeholder="请输入"
              @blur="blurEvent('amountIsEdit')"
              @input="inputEvent($event, 'amount', 'amountIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.amount }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="export"
          label="出口"
          align="center"
          fixed="left"
          width="40"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.exportIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.export"
              @blur="blurEvent('exportIsEdit')"
              @input="inputEvent($event, 'export', 'exportIsEdit')"
              @focus="focusEvent(scope)"
              placeholder="请输入"
            ></el-input>
            <span v-else>{{ scope.row.export }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="excessive"
          label="类型备注"
          fixed="left"
          align="center"
          width="50"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.excessiveIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.excessive"
              @blur="blurEvent('excessiveIsEdit')"
              @input="inputEvent($event, 'excessive', 'excessiveIsEdit')"
              @focus="focusEvent(scope)"
              placeholder="请输入"
            ></el-input>
            <span v-else>{{ scope.row.excessive }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="specs"
          label="规格"
          align="center"
          width="76"
          fixed="left"
          sortable="custom"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.specsIsEdit) && (isAdmin || isQC)
              "
              v-model="scope.row.specs"
              placeholder="请输入"
              @blur="blurEvent('specsIsEdit')"
              @input="inputEvent($event, 'specs', 'specsIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.specs }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="unit"
          label="单位"
          align="center"
          width="40"
          fixed="left"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.unitIsEdit) && (isAdmin || isQC)
              "
              v-model="scope.row.unit"
              placeholder="请输入"
              @blur="blurEvent('unitIsEdit')"
              @input="inputEvent($event, 'unit', 'unitIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.unit }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="toleranceDown"
          label="公差下限"
          align="center"
          width="70"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.toleranceDownIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.toleranceDown"
              placeholder="请输入"
              @blur="blurEvent('toleranceDownIsEdit')"
              @input="
                inputEvent($event, 'toleranceDown', 'toleranceDownIsEdit')
              "
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.toleranceDown }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="toleranceUp"
          label="公差上限"
          align="center"
          width="70"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.toleranceUpIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.toleranceUp"
              placeholder="请输入"
              @blur="blurEvent('toleranceUpIsEdit')"
              @input="inputEvent($event, 'toleranceUp', 'toleranceUpIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.toleranceUp }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="shellSize"
          label="外壳尺寸"
          width="70"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.shellSizeIsEdit) &&
                (isAdmin || isQC)
              "
              v-model="scope.row.shellSize"
              placeholder="请输入"
              @blur="blurEvent('shellSizeIsEdit')"
              @input="inputEvent($event, 'shellSize', 'shellSizeIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>

            <span v-else>{{ scope.row.shellSize }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="itemNo"
          label="客户指定料号"
          align="center"
          width="68"
        >
          <template slot-scope="scope">
            <el-input
              v-if="(scope.row.isEdit || scope.row.itemNoIsEdit) && isAdmin"
              v-model="scope.row.itemNo"
              placeholder="请输入"
              @blur="blurEvent('itemNoIsEdit')"
              @input="inputEvent($event, 'itemNo', 'itemNoIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.itemNo }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="compressDown"
          label="压缩角公差下限"
          align="center"
          width="77"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.compressDownIsEdit) &&
                (isTechnology || isAdmin)
              "
              v-model="scope.row.compressDown"
              placeholder="请输入"
              @blur="blurEvent('compressDownIsEdit')"
              @input="inputEvent($event, 'compressDown', 'compressDownIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.compressDown }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="compressUp"
          label="压缩角公差上限"
          align="center"
          width="77"
        >
          <template slot-scope="scope">
            <el-input
              v-if="(scope.row.isEdit || scope.row.compressUpIsEdit) && isAdmin"
              v-model="scope.row.compressUp"
              placeholder="请输入"
              @blur="blurEvent('compressUpIsEdit')"
              @input="inputEvent($event, 'compressUp', 'compressUpIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.compressUp }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="dingjingDown"
          label="定径公差下限"
          align="center"
          width="68"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.dingjingDownIsEdit) && isAdmin
              "
              v-model="scope.row.dingjingDown"
              placeholder="请输入"
              @blur="blurEvent('dingjingDownIsEdit')"
              @input="inputEvent($event, 'dingjingDown', 'dingjingDownIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.dingjingDown }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="dingjingUp"
          label="定径公差上限"
          align="center"
          width="68"
        >
          <template slot-scope="scope">
            <el-input
              v-if="(scope.row.isEdit || scope.row.dingjingUpIsEdit) && isAdmin"
              v-model="scope.row.dingjingUp"
              placeholder="请输入"
              @blur="blurEvent('dingjingUpIsEdit')"
              @input="inputEvent($event, 'dingjingUp', 'dingjingUpIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.dingjingUp }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="roughSupplier"
          label="供应商代码"
          align="center"
          width="77"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.roughSupplierIsEdit) &&
                (isTechnology || isAdmin)
              "
              v-model="scope.row.roughSupplier"
              placeholder="请输入"
              @blur="blurEvent('roughSupplierIsEdit')"
              @input="
                inputEvent($event, 'roughSupplier', 'roughSupplierIsEdit')
              "
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.roughSupplier }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="roughItemNo"
          label="料号"
          align="center"
          width="60"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.roughItemNoIsEdit) &&
                (isTechnology || isAdmin)
              "
              v-model="scope.row.roughItemNo"
              placeholder="请输入"
              @blur="blurEvent('roughItemNoIsEdit')"
              @input="inputEvent($event, 'roughItemNo', 'roughItemNoIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.roughItemNo }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="compressDown2"
          label="压缩角公差下限2"
          align="center"
          width="77"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.compressDown2IsEdit) &&
                (isTechnology || isAdmin)
              "
              v-model="scope.row.compressDown2"
              placeholder="请输入"
              @blur="blurEvent('compressDown2IsEdit')"
              @input="
                inputEvent($event, 'compressDown2', 'compressDown2IsEdit')
              "
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.compressDown2 }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="compressUp2"
          label="压缩角公差上限2"
          align="center"
          width="77"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.compressUp2IsEdit) &&
                (isTechnology || isAdmin)
              "
              v-model="scope.row.compressUp2"
              placeholder="请输入"
              @blur="blurEvent('compressUp2IsEdit')"
              @input="inputEvent($event, 'compressUp2', 'compressUp2IsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.compressUp2 }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="dingjingDown2"
          label="定径公差下限2"
          width="77"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.dingjingDown2IsEdit) &&
                (isTechnology || isAdmin)
              "
              v-model="scope.row.dingjingDown2"
              placeholder="请输入"
              @blur="blurEvent('dingjingDown2IsEdit')"
              @input="
                inputEvent($event, 'dingjingDown2', 'dingjingDown2IsEdit')
              "
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.dingjingDown2 }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="dingjingUp2"
          label="定径公差上限2"
          width="77"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.dingjingUp2IsEdit) &&
                (isTechnology || isAdmin)
              "
              v-model="scope.row.dingjingUp2"
              placeholder="请输入"
              @blur="blurEvent('dingjingUp2IsEdit')"
              @input="inputEvent($event, 'dingjingUp2', 'dingjingUp2IsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.dingjingUp2 }}</span>
          </template>
        </el-table-column>

        <el-table-column
          prop="custNo"
          label="客户代码"
          align="center"
          width="56"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.custNoIsEdit) &&
                (isQC || isAdmin)
              "
              v-model="scope.row.custNo"
              placeholder="请输入"
              @blur="blurEvent('custNoIsEdit')"
              @input="inputEvent($event, 'custNo', 'custNoIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.custNo }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="numberStart"
          label="模具起始编号"
          width="80"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.numberStartIsEdit) &&
                (isQC || isAdmin)
              "
              v-model="scope.row.numberStart"
              placeholder="请输入"
              @blur="blurEvent('numberStartIsEdit')"
              @input="inputEvent($event, 'numberStart', 'numberStartIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.numberStart }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="numberEnd"
          label="模具结束编号"
          width="80"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              v-if="
                (scope.row.isEdit || scope.row.numberEndIsEdit) &&
                (isQC || isAdmin)
              "
              v-model="scope.row.numberEnd"
              placeholder="请输入"
              @blur="blurEvent('numberEndIsEdit')"
              @input="inputEvent($event, 'numberEnd', 'numberEndIsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.numberEnd }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="front9"
          label="正面9点"
          align="center"
          width="60"
        >
          <template slot-scope="scope">
            <el-input
              v-if="(scope.row.isEdit || scope.row.front9IsEdit) && isAdmin"
              v-model="scope.row.front9"
              placeholder="请输入"
              @blur="blurEvent('front9IsEdit')"
              @input="inputEvent($event, 'front9', 'front9IsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.front9 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="front3"
          label="正面3点"
          align="center"
          width="60"
        >
          <template slot-scope="scope">
            <el-input
              v-if="(scope.row.isEdit || scope.row.front3IsEdit) && isAdmin"
              v-model="scope.row.front3"
              placeholder="请输入"
              @blur="blurEvent('front3IsEdit')"
              @input="inputEvent($event, 'front3', 'front3IsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.front3 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="reverse9"
          label="反面9点"
          align="center"
          width="60"
        >
          <template slot-scope="scope">
            <el-input
              v-if="(scope.row.isEdit || scope.row.reverse9IsEdit) && isAdmin"
              v-model="scope.row.reverse9"
              placeholder="请输入"
              @blur="blurEvent('reverse9IsEdit')"
              @input="inputEvent($event, 'reverse9', 'reverse9IsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.reverse9 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="reverse3"
          label="反面3点"
          align="center"
          width="60"
        >
          <template slot-scope="scope">
            <el-input
              v-if="(scope.row.reverse3IsEdit || scope.row.isEdit) && isAdmin"
              v-model="scope.row.reverse3"
              placeholder="请输入"
              @blur="blurEvent('reverse3IsEdit')"
              @input="inputEvent($event, 'reverse3', 'reverse3IsEdit')"
              @focus="focusEvent(scope)"
            ></el-input>
            <span v-else>{{ scope.row.reverse3 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.isEdit"
              type="text"
              @click="saveRow(scope.$index)"
              >保存</el-button
            >
            <el-button
              v-else
              type="text"
              @click="editRow(scope.row, scope.$index)"
              >编辑</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <div class="mt_10 mb_10">注：{{ orderInfo.remark }}</div>
      <div class="d-flex font-bold">
        <div class="w_20">生产课：{{ orderInfo.production }}</div>
        <div class="w_20">品管：{{ orderInfo.qc }}</div>
        <div class="w_20">计划：{{ orderInfo.plan }}</div>
        <div class="w_20">技术：{{ orderInfo.technology }}</div>
        <div class="w_20">业务：{{ orderInfo.business }}</div>
      </div>
      <div class="d-flex mb_20 font-bold">
        <div class="w_20">日期：{{ orderInfo.productionDate }}</div>
        <div class="w_20">日期：{{ orderInfo.qcDate }}</div>
        <div class="w_20">日期：{{ orderInfo.planDate }}</div>
        <div class="w_20">日期：{{ orderInfo.technologyDate }}</div>
        <div class="w_20">日期：{{ orderInfo.businessDate }}</div>
      </div>
    </div>
    <el-button @click="orderParamPtinrDialogVisible = true" type="primary"
      >参数打印</el-button
    >

    <el-upload
      v-if="isProduction || isAdmin"
      class="upload-demo"
      style="margin-top: -32px; margin-left: 100px"
      :action="exportUrl"
      :data="{ type: 'N' }"
      :limit="1"
      :file-list="fileList"
      :on-success="successUpload"
      :show-file-list="false"
    >
      <el-button size="small" type="primary" v-if="isProduction || isAdmin"
        >参数重导</el-button
      >
    </el-upload>
    <!-- 这里是显示的 -->
    <div id="paramPrint1">
      <h3 class="t_a mb_20" id="test" style="font-size: 22px">
        单号 {{ orderInfo.orderNo }} 参数表
      </h3>
      <el-table
        class="mt_20"
        max-height="600"
        :data="parameters"
        style="font-size: 14px; font-weight: 600"
        border
        :header-row-style="rowHeader"
      >
        <el-table-column
          prop="seque"
          label="序号"
          width="40"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="material"
          label="材质"
          width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="specs"
          label="规格"
          width="80"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="aperture"
          label="需到孔径"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="angle"
          label="角度"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="extent"
          label="定径长度"
          align="center"
        ></el-table-column>

        <el-table-column label="品管" align="center">
          <el-table-column label="包装" align="center">
            <el-table-column prop="qcbz" align="center"></el-table-column>
          </el-table-column>
          <el-table-column label="打码" align="center">
            <el-table-column prop="qcdm" align="center"></el-table-column>
          </el-table-column>

          <el-table-column label="车制" align="center">
            <el-table-column prop="qccz" align="center"></el-table-column>
          </el-table-column>

          <el-table-column label="挪检" align="center">
            <el-table-column prop="qclj" align="center"></el-table-column>
          </el-table-column>

          <el-table-column label="镜检" align="center">
            <el-table-column prop="qcjj" align="center"></el-table-column>
          </el-table-column>
        </el-table-column>
        <el-table-column
          prop="research2"
          label="二研"
          width="50"
          align="center"
        ></el-table-column>
        <el-table-column label="设定" align="center">
          <el-table-column label="上限" align="center">
            <el-table-column
              prop="djAllowanceUp1"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="djAllowanceUp2"
              align="center"
            ></el-table-column>
          </el-table-column>
          <el-table-column label="下限" align="center">
            <el-table-column
              prop="djAllowanceDown1"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="djAllowanceDown2"
              align="center"
            ></el-table-column>
          </el-table-column>
        </el-table-column>

        <el-table-column
          prop="research1"
          label="一研"
          width="50"
          align="center"
        ></el-table-column>

        <el-table-column label="过粉（上）" align="center">
          <el-table-column
            prop="gf1Up"
            label="上限"
            align="center"
            width="100"
          ></el-table-column>
          <el-table-column
            prop="gf1Down"
            label="下限"
            align="center"
            width="100"
          ></el-table-column>
        </el-table-column>

        <el-table-column label="斜线" align="center">
          <el-table-column
            prop="xxAllowanceUp"
            label="上限"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="xxAllowanceDown"
            label="下限"
            align="center"
          ></el-table-column>
        </el-table-column>
        <el-table-column label="斜线取线" align="center">
          <el-table-column label="过线模" align="center">
            <el-table-column prop="takeLine1" align="center"></el-table-column>
            <el-table-column prop="takeLine2" align="center"></el-table-column>
          </el-table-column>
          <el-table-column
            prop="takeLine3"
            label="母线"
            align="center"
          ></el-table-column>
        </el-table-column>

        <el-table-column label="一设" align="center">
          <el-table-column
            prop="ysUp"
            label="上限"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="ysDown"
            label="下限"
            align="center"
          ></el-table-column>
        </el-table-column>

        <el-table-column label="过粉（下）" align="center">
          <el-table-column
            prop="gf2Up"
            label="上限"
            align="center"
            width="100"
          ></el-table-column>
          <el-table-column
            prop="gf2Down"
            label="下限"
            align="center"
            width="100"
          ></el-table-column>
        </el-table-column>

        <el-table-column label="成形" align="center">
          <el-table-column
            prop="cxAllowanceUp"
            label="上限"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="cxAllowanceDown"
            label="下限"
            align="center"
          ></el-table-column>
        </el-table-column>
        <el-table-column label="扩大" align="center">
          <el-table-column
            prop="kdAllowanceUp"
            label="上限"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="kdAllowanceDown"
            label="下限"
            align="center"
          ></el-table-column>
        </el-table-column>
        <el-table-column
          prop="plastic"
          label="整形"
          align="center"
        ></el-table-column>
        <el-table-column label="激光参数" align="center">
          <el-table-column label="上限" align="center">
            <el-table-column
              prop="laserParamUp1"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="laserParamUp2"
              align="center"
            ></el-table-column>
          </el-table-column>
          <el-table-column label="下限" align="center">
            <el-table-column
              prop="laserParamDown1"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="laserParamDown2"
              align="center"
            ></el-table-column>
          </el-table-column>
          <el-table-column
            prop="laserParamAngle"
            label="角度"
            align="center"
          ></el-table-column>
        </el-table-column>

        <el-table-column
          prop="unumber"
          label="µ数"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="tangentValue"
          label="正切值"
          align="center"
        ></el-table-column>
      </el-table>
    </div>

    <!-- 此处是打印的 -->
    <el-dialog :visible.sync="orderParamPtinrDialogVisible" width="1337px">
      <el-button @click="orderParamPtinrDialogVisible = false"
        >取消打印</el-button
      >
      <el-button v-print="'#paramPrint'" type="primary">确定打印</el-button>
      <div id="paramPrint">
        <h3 class="t_a mb_20" id="test" style="font-size: 14px">
          单号 {{ orderInfo.orderNo }} 参数表
        </h3>
        <el-table
          class="mt_20"
          :data="parameters"
          style="font-size: 14px; font-weight: 600"
          border
        >
          <el-table-column
            prop="seque"
            label="序号"
            width="40"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="material"
            label="材质"
            v-if="materialShow"
            width="50"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="specs"
            v-if="specsShow"
            label="规格"
            width="70"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="aperture"
            width="70"
            v-if="apertureShow"
            label="需到孔径"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="angle"
            v-if="angleShow"
            width="70"
            label="角度"
            align="center"
          ></el-table-column>
          <el-table-column
            prop="extent"
            v-if="extentShow"
            width="70"
            label="定径长度"
            align="center"
          ></el-table-column>

          <el-table-column
            label="品管"
            align="center"
            v-if="qcbzShow || qcdmShow || qcczShow || qcljShow || qcjjShow"
          >
            <el-table-column label="包装" align="center" v-if="qcbzShow">
              <el-table-column prop="qcbz" align="center"></el-table-column>
            </el-table-column>
            <el-table-column label="打码" align="center" v-if="qcdmShow">
              <el-table-column prop="qcdm" align="center"></el-table-column>
            </el-table-column>

            <el-table-column label="车制" align="center" v-if="qcczShow">
              <el-table-column prop="qccz" align="center"></el-table-column>
            </el-table-column>

            <el-table-column label="挪检" align="center" v-if="qcljShow">
              <el-table-column prop="qclj" align="center"></el-table-column>
            </el-table-column>

            <el-table-column label="镜检" align="center" v-if="qcjjShow">
              <el-table-column prop="qcjj" align="center"></el-table-column>
            </el-table-column>
          </el-table-column>

          <el-table-column
            prop="research2"
            v-if="research2Show"
            label="二研"
            width="50"
            align="center"
          ></el-table-column>

          <el-table-column
            label="设定"
            align="center"
            v-if="djAllowanceUp1Show || djAllowanceUp2Show"
          >
            <el-table-column label="上限" align="center">
              <el-table-column
                prop="djAllowanceUp1"
                align="center"
              ></el-table-column>
              <el-table-column
                prop="djAllowanceUp2"
                align="center"
              ></el-table-column>
            </el-table-column>
            <el-table-column label="下限" align="center">
              <el-table-column
                prop="djAllowanceDown1"
                align="center"
              ></el-table-column>
              <el-table-column
                prop="djAllowanceDown2"
                align="center"
              ></el-table-column>
            </el-table-column>
          </el-table-column>

          <el-table-column
            prop="research1"
            v-if="research1Show"
            label="一研"
            width="50"
            align="center"
          ></el-table-column>

          <el-table-column label="过粉（上）" align="center" v-if="gf1UpShow">
            <el-table-column
              prop="gf1Up"
              label="上限"
              align="center"
              width="70"
            ></el-table-column>
            <el-table-column
              prop="gf1Down"
              v-if="gf1Down"
              label="下限"
              align="center"
              width="70"
            ></el-table-column>
          </el-table-column>

          <el-table-column label="斜线" align="center" v-if="xxAllowanceUpShow">
            <el-table-column
              prop="xxAllowanceUp"
              label="上限"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="xxAllowanceDown"
              label="下限"
              align="center"
            ></el-table-column>
          </el-table-column>
          <el-table-column
            label="斜线取线"
            align="center"
            v-if="takeLine1Show || takeLine2Show || takeLine3Show"
          >
            <el-table-column label="过线模" align="center">
              <el-table-column
                prop="takeLine1"
                v-if="takeLine1Show"
                align="center"
              ></el-table-column>
              <el-table-column
                prop="takeLine2"
                v-if="takeLine2Show"
                align="center"
                width="70"
              ></el-table-column>
            </el-table-column>
            <el-table-column
              prop="takeLine3"
              v-if="takeLine3Show"
              label="母线"
              width="70"
              align="center"
            ></el-table-column>
          </el-table-column>

          <el-table-column label="一设" align="center" v-if="ysUpShow">
            <el-table-column
              prop="ysUp"
              label="上限"
              width="70"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="ysDown"
              label="下限"
              width="70"
              align="center"
            ></el-table-column>
          </el-table-column>

          <el-table-column label="过粉（下）" align="center" v-if="gf2UpShow">
            <el-table-column
              prop="gf2Up"
              label="上限"
              align="center"
              width="70"
            ></el-table-column>
            <el-table-column
              prop="gf2Down"
              label="下限"
              align="center"
              width="70"
            ></el-table-column>
          </el-table-column>

          <el-table-column label="成形" align="center" v-if="cxAllowanceUpShow">
            <el-table-column
              prop="cxAllowanceUp"
              label="上限"
              width="70"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="cxAllowanceDown"
              label="下限"
              align="center"
              width="70"
            ></el-table-column>
          </el-table-column>
          <el-table-column label="扩大" align="center" v-if="kdAllowanceUpShow">
            <el-table-column
              prop="kdAllowanceUp"
              label="上限"
              width="70"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="kdAllowanceDown"
              label="下限"
              width="70"
              align="center"
            ></el-table-column>
          </el-table-column>
          <el-table-column
            prop="plastic"
            v-if="plasticShow"
            label="整形"
            width="70"
            align="center"
          ></el-table-column>
          <el-table-column
            label="激光参数"
            align="center"
            v-if="
              laserParamUp1Show ||
              laserParamUp2Show ||
              laserParamDown1Show ||
              laserParamDown2Show ||
              laserParamAngleShow
            "
          >
            <el-table-column label="上限" align="center">
              <el-table-column
                prop="laserParamUp1"
                align="center"
                width="70"
              ></el-table-column>
              <el-table-column
                prop="laserParamUp2"
                align="center"
                width="70"
              ></el-table-column>
            </el-table-column>
            <el-table-column label="下限" align="center">
              <el-table-column
                prop="laserParamDown1"
                width="70"
                align="center"
              ></el-table-column>
              <el-table-column
                prop="laserParamDown2"
                width="70"
                align="center"
              ></el-table-column>
            </el-table-column>
            <el-table-column
              prop="laserParamAngle"
              width="70"
              label="角度"
              align="center"
            ></el-table-column>
          </el-table-column>

          <el-table-column
            prop="unumber"
            v-if="uNumberShow"
            width="70"
            label="µ数"
            align="center"
          ></el-table-column>
          <el-table-column
            v-if="tangentValueShow"
            prop="tangentValue"
            width="70"
            label="正切值"
            align="center"
          ></el-table-column>
        </el-table>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import api from "../../../api";
import print from "print-js";
import host from "@/utils/host";
import { RoleType } from "../../common/enum";
export default {
  name: "orderDetail",
  data() {
    return {
      exportUrl: host.host + "file/open/fileUpload",
      isLoading: false,
      orderPtinrDialogVisible: false,
      orderParamPtinrDialogVisible: false,
      orderItem: [],
      orderItem2: [],
      parameters: [],
      editInfo: {
        id: null,
        orderNo: null,
        seque: null,
        productName: null,
        custProcuctName: null,
        export: null,
        excessive: null,
        cardName: null,
        specs: null,
        unit: null,
        amount: null,
        toleranceUp: null,
        toleranceDown: null,
        shellSize: null,
        itemNo: null,
        compress: null,
        dingjing: null,
        roughSupplier: null,
        roughItemNo: null,
        compressUp: null,
        compressDown: null,
        dingjingUp: null,
        dingjingDown: null,
        compressUp2: null,
        compressDown2: null,
        dingjingUp2: null,
        dingjingDown2: null,
        custNo: null,
        numberStart: null,
        numberEnd: null,
        front9: null,
        front3: null,
        reverse9: null,
        reverse3: null,
        type: null,
      },
      isBusiness: false, // 业务
      isQC: false, // 品管
      isPlan: false, // 计划
      isProduction: false,
      isTechnology: false, // 技术
      isAdmin: false,
      orderInfo: {},
      showEditDate: false,
      showEditRequirement2: false,
      requirement2: null,
      replyDate: null,
      editIndex: 0,
      orderProperty: "seque",
      sortOrder: "ascending",
      qcbzShow: true,
      qcdmShow: true,
      qcczShow: true,
      qcljShow: true,
      qcjjShow: true,
      research2Show: true,
      djAllowanceUp1Show: true,
      djAllowanceUp2Show: true,
      djAllowanceDown1Show: true,
      djAllowanceDown2Show: true,
      research1Show: true,
      gf1UpShow: true,
      gf1DownShow: true,
      xxAllowanceUpShow: true,
      xxAllowanceDownShow: true,
      takeLine1Show: true,
      takeLine2Show: true,
      takeLine3Show: true,
      ysUpShow: true,
      ysDownShow: true,
      gf2UpShow: true,
      gf2DownShow: true,
      cxAllowanceUpShow: true,
      cxAllowanceDownShow: true,
      kdAllowanceUpShow: true,
      kdAllowanceDownShow: true,
      laserParamUp1Show: true,
      laserParamUp2Show: true,
      laserParamDown1Show: true,
      laserParamDown2Show: true,
      laserParamAngleShow: true,
      plasticShow: true,
      uNumberShow: true,
      tangentValueShow: true,
      materialShow: true,
      specsShow: true,
      apertureShow: true,
      angleShow: true,
      extentShow: true,
    };
  },
  mounted() {
    console.info("mounted");
    this.getData();
    let user = sessionStorage.getItem("adminUserInfo");
    if (user) {
      user = JSON.parse(user);
      console.info("用户信息", user);
      this.isBusiness = user.role === RoleType.Business;
      this.isQC = user.role === RoleType.QC;
      this.isPlan = user.role === RoleType.Plan;
      this.isTechnology = user.role === RoleType.Technology;
      this.isAdmin = user.role === RoleType.Admin;
      this.isProduction = user.role === RoleType.Production;
    }
  },
  methods: {
    successUpload(response, file, fileList) {
      this.fileList = [];
      console.info("文件导入成功" + response);
      api
        .paramRetry({
          parameterUrl: response.data,
          orderNo: this.orderInfo.orderNo,
        })
        .then((res) => {
          this.$message.success("导入成功");
          this.getData();
        });
    },

    bindPrint() {
      console.info("打印");
      print({ printable: "paramPrint" });
      // print({
      //   printable: "paramPrint",
      //   ignoreElements: ["test"],
      //   type: "pdf",
      //   documentTitle: "参数打印",
      //   header: "参数打印",
      //   maxWidth: 2800,
      //   targetStyles: ["*"],
      //   style: "@page {margin:0 10mm}",
      // });
    },

    getData() {
      console.info("getData");
      this.isLoading = true;
      api
        .getInsideOrderDetail({
          orderNo: this.$route.query.id,
        })
        .then((res) => {
          if (res.code === 200) {
            this.orderInfo = res.data.insideOrder;
            this.requirement2 = res.data.insideOrder.requirement2;
            this.orderItem = res.data.orderItem.map((x) => {
              var index = 0;
              return {
                ...x,
                isEdit: false,
                specsIsEdit: false,
                amountIsEdit: false,
                toleranceUpIsEdit: false,
                toleranceDownIsEdit: false,
                shellSizeIsEdit: false,
                itemNoIsEdit: false,
                compressIsEdit: false,
                compressIsEdit: false,
                dingjingIsEdit: false,
                reverse3IsEdit: false,
                roughSupplierIsEdit: false,
                roughItemNoIsEdit: false,
                compressUpIsEdit: false,
                compressDownIsEdit: false,
                dingjingUpIsEdit: false,
                dingjingDownIsEdit: false,
                compressUp2IsEdit: false,
                compressDown2IsEdit: false,
                dingjingUp2IsEdit: false,
                dingjingDown2IsEdit: false,
                custNoIsEdit: false,
                numberStartIsEdit: false,
                numberEndIsEdit: false,
                front9IsEdit: false,
                front3IsEdit: false,
                reverse9IsEdit: false,
                reverse3IsEdit: false,
                cardNameIsEdit: false,
                excessiveIsEdit: false,
                exportIsEdit: false,
                productNameIsEdit: false,
                custProcuctNameIsEdit: false,
                unitIsEdit: false,
                index: index++,
              };
            });
            console.info(this.orderItem);
            this.orderItem.sort(
              this.compare(this.orderProperty, this.sortOrder)
            );
            this.orderItem2 = this.clone(this.orderItem);
            this.orderItem2.sort(
              this.compare(this.orderProperty, this.sortOrder)
            );
            this.parameters = res.data.parameters;
            if (this.parameters.length > 0) {
              let it = this.parameters[0];
              if (it.material == "" || it.material == "0") {
                this.materialShow = false;
              }
              if (it.specs == "" || it.specs == "0") {
                this.specsShow = false;
              }
              if (it.aperture == "" || it.aperture == "0") {
                this.apertureShow = false;
              }
              if (it.angle == "" || it.angle == "0") {
                this.angleShow = false;
              }
              if (it.extent == "" || it.extent == "0") {
                this.extentShow = false;
              }
              if (it.qcbz == "" || it.qcbz == "0") {
                this.qcbzShow = false;
              }
              if (it.qcdm == "" || it.qcdm == "0") {
                this.qcdmShow = false;
              }
              if (it.qccz == "" || it.qccz == "0") {
                this.qcczShow = false;
              }
              if (it.qclj == "" || it.qclj == "0") {
                this.qcljShow = false;
              }
              if (it.qcjj == "" || it.qcjj == "0") {
                this.qcjjShow = false;
              }
              if (it.research2 == "" || it.research2 == "0") {
                this.research2Show = false;
              }
              if (it.djAllowanceUp1 == "" || it.djAllowanceUp1 == "0") {
                this.djAllowanceUp1Show = false;
              }
              if (it.djAllowanceUp2 == "" || it.djAllowanceUp2 == "0") {
                this.djAllowanceUp2Show = false;
              }
              if (it.djAllowanceDown1 == "" || it.djAllowanceDown1 == "0") {
                this.djAllowanceDown1Show = false;
              }
              if (it.djAllowanceDown2 == "" || it.djAllowanceDown2 == "0") {
                this.djAllowanceDown2Show = false;
              }
              if (it.research1 == "" || it.research1 == "0") {
                this.research1Show = false;
              }
              if (it.gf1Up == "" || it.gf1Up == "0") {
                this.gf1UpShow = false;
              }
              if (it.gf1Down == "" || it.gf1Down == "0") {
                this.gf1DownShow = false;
              }
              if (it.xxAllowanceUp == "" || it.xxAllowanceUp == "0") {
                this.xxAllowanceUpShow = false;
              }
              if (it.xxAllowanceDown == "" || it.xxAllowanceDown == "0") {
                this.xxAllowanceDownShow = false;
              }
              if (it.takeLine1 == "" || it.takeLine1 == "0") {
                this.takeLine1Show = false;
              }
              if (it.takeLine2 == "" || it.takeLine2 == "0") {
                this.takeLine2Show = false;
              }
              if (it.takeLine3 == "" || it.takeLine3 == "0") {
                this.takeLine3Show = false;
              }
              if (it.ysUp == "" || it.ysUp == "0") {
                this.ysUpShow = false;
              }
              if (it.ysDown == "" || it.ysDown == "0") {
                this.ysDownShow = false;
              }
              if (it.gf2Up == "" || it.gf2Up == "0") {
                this.gf2UpShow = false;
              }
              if (it.gf2Down == "" || it.gf2Down == "0") {
                this.gf2DownShow = false;
              }
              if (it.cxAllowanceUp == "" || it.cxAllowanceUp == "0") {
                this.cxAllowanceUpShow = false;
              }
              if (it.cxAllowanceDown == "" || it.cxAllowanceDown == "0") {
                this.cxAllowanceDownShow = false;
              }
              if (it.kdAllowanceUp == "" || it.kdAllowanceUp == "0") {
                this.kdAllowanceUpShow = false;
              }
              if (it.kdAllowanceDown == "" || it.kdAllowanceDown == "0") {
                this.kdAllowanceDownShow = false;
              }

              if (it.laserParamUp1 == "" || it.laserParamUp1 == "0") {
                this.laserParamUp1Show = false;
              }

              if (it.laserParamUp2 == "" || it.laserParamUp2 == "0") {
                this.laserParamUp2Show = false;
              }
              if (it.laserParamDown1 == "" || it.laserParamDown1 == "0") {
                this.laserParamDown1Show = false;
              }
              if (it.laserParamDown2 == "" || it.laserParamDown2 == "0") {
                this.laserParamDown2Show = false;
              }
              if (it.laserParamAngle == "" || it.laserParamAngle == "0") {
                this.laserParamAngleShow = false;
              }
              if (it.plastic == "" || it.plastic == "0") {
                this.plasticShow = false;
              }
              if (it.uNumber == "" || it.uNumber == "0") {
                this.uNumberShow = false;
              }
              if (it.tangentValue == "" || it.tangentValue == "0") {
                this.tangentValueShow = false;
              }
            }

            console.info("qcbzShow==", this.qcbzShow);

            this.isLoading = false;
          }
        })
        .catch((this.isLoading = false));
    },

    clone(obj) {
      if (Array.isArray(obj)) {
        // 赋值数据 而不是地址
        // 对于引用数据类型 将对象中的值进行一次赋值
        var arr = [];
        for (var i = 0; i < obj.length; i++) {
          arr.push(this.clone(obj[i]));
        }
        return arr;
      } else if (Object.prototype.toString.call(obj) === "[object Object]") {
        var newObj = {};
        for (var key in obj) {
          newObj[key] = this.clone(obj[key]);
          // 基本数据类型不受影响，引用数据类型也不受影响
        }
        return newObj;
      } else {
        return obj; //这是是递归函数的出口
      }
    },

    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        if (index === 3) {
          const values = data.map((item) => Number(item[column.property]));
          if (!values.every((value) => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
          }
        } else {
          sums[index] = "";
        }
      });
      return sums;
    },
    rowHeader(row, rowIndex) {
      if (row.rowIndex == 2) {
        return { display: "none" };
      }
    },
    editRow(row, index) {
      this.$set(this.orderItem[index], "isEdit", true);
      this.editInfo = JSON.parse(JSON.stringify(row));
    },

    cancel() {
      this.orderItem = this.clone(this.orderItem2);
      console.info("orderItem", this.orderItem);
    },

    save() {
      console.info("保存订单项信息", this.orderItem);
      api.updateOrderItem(this.orderItem).then((res) => {
        console.info(res);
        this.editIndex = 0;
        this.orderProperty = "seque";
        this.sortOrder = "ascending";
        this.getData();
      });
    },
    //双击单元格
    cellDbClick(row, column, cell, event) {
      console.info("cellDbClick");
      console.info(this.orderProperty);
      console.info(this.sortOrder);
      console.info(column.property);
      console.info(column);
      console.info(cell);
      // console.info("".indexOf("技术"));
      //如果当前角色已经审核过了 就不允许再编辑 除了管理员
      // isQC: false, // 品管
      //   isPlan: false, // 计划
      //   isTechnology: false, // 技术
      //   isAdmin: false,
      var checkRecords =
        this.orderInfo.checkRecords == null ? "" : this.orderInfo.checkRecords;
      if (this.isQC && checkRecords.indexOf("品管") != -1) {
        console.info("品管已审核 不允许再修改");
        return;
      }
      if (this.isPlan && checkRecords.indexOf("计划") != -1) {
        console.info("计划已审核 不允许再修改");
        return;
      }
      if (this.isTechnology && checkRecords.indexOf("技术") != -1) {
        console.info("技术已审核 不允许再修改");
        return;
      }
      var property = "";
      if (column.property == "roughSupplier") {
        property = "roughSupplierIsEdit";
      } else if (column.property == "roughItemNo") {
        property = "roughItemNoIsEdit";
      } else if (column.property == "compressUp") {
        property = "compressUpIsEdit";
      } else if (column.property == "compressDown") {
        property = "compressDownIsEdit";
      } else if (column.property == "dingjingUp") {
        property = "dingjingUpIsEdit";
      } else if (column.property == "dingjingDown") {
        property = "dingjingDownIsEdit";
      } else if (column.property == "custNo") {
        property = "custNoIsEdit";
      } else if (column.property == "numberStart") {
        property = "numberStartIsEdit";
      } else if (column.property == "numberEnd") {
        property = "numberEndIsEdit";
      } else if (column.property == "front9") {
        property = "front9IsEdit";
      } else if (column.property == "front3") {
        property = "front3IsEdit";
      } else if (column.property == "reverse9") {
        property = "reverse9IsEdit";
      } else if (column.property == "reverse3") {
        property = "reverse3IsEdit";
      } else if (column.property == "specs") {
        property = "specsIsEdit";
      } else if (column.property == "amount") {
        property = "amountIsEdit";
      } else if (column.property == "toleranceUp") {
        property = "toleranceUpIsEdit";
      } else if (column.property == "toleranceDown") {
        property = "toleranceDownIsEdit";
      } else if (column.property == "shellSize") {
        property = "shellSizeIsEdit";
      } else if (column.property == "itemNo") {
        property = "itemNoIsEdit";
      } else if (column.property == "compress") {
        property = "compressIsEdit";
      } else if (column.property == "dingjing") {
        property = "dingjingIsEdit";
      } else if (column.property == "cardName") {
        property = "cardNameIsEdit";
      } else if (column.property == "excessive") {
        property = "excessiveIsEdit";
      } else if (column.property == "export") {
        property = "exportIsEdit";
      } else if (column.property == "productName") {
        property = "productNameIsEdit";
      } else if (column.property == "custProcuctName") {
        property = "custProcuctNameIsEdit";
      } else if (column.property == "unit") {
        property = "unitIsEdit";
      } else if (column.property == "compressUp2") {
        property = "compressUp2IsEdit";
      } else if (column.property == "compressDown2") {
        property = "compressDown2IsEdit";
      } else if (column.property == "dingjingUp2") {
        property = "dingjingUp2IsEdit";
      } else if (column.property == "dingjingDown2") {
        property = "dingjingDown2IsEdit";
      }
      console.info("property", property);
      for (var index = 0; index < this.orderItem.length; index++) {
        if (this.sortOrder == "ascending") {
          if (this.orderItem[index].index >= row.index) {
            // this.$set(this.orderItem[index], property, true);
            this.orderItem[index][property] = true;
          }
        } else {
          if (this.orderItem[index].index <= row.index) {
            // this.$set(this.orderItem[index], property, true);
            this.orderItem[index][property] = true;
          }
        }
      }
      console.info(this.orderItem);
    },

    sortChange(param) {
      console.info(param.prop);
      console.info(param.order);
      this.orderProperty = param.prop;
      this.sortOrder = param.order;
      this.orderItem.sort(this.compare(this.orderProperty, this.sortOrder));
      //  每次排序之后重新赋值下标  便于后面使用
      for (var index = 0; index < this.orderItem.length; index++) {
        this.orderItem[index].index = index;
      }

      console.info(this.orderItem);
    },

    compare(property, order) {
      return function (a, b) {
        var value1 = a[property];
        var value2 = b[property];
        if (order == "ascending") {
          return value1 - value2;
        } else {
          return value2 - value1;
        }
      };
    },
    // 在 Input 获得焦点时触发
    focusEvent(scope) {
      this.editIndex = scope.$index;
    },

    // 在 Input 失去焦点时触发
    blurEvent(property) {
      console.info("blurEvent");
      if (property == "numberStartIsEdit" || property == "numberEndIsEdit") {
        return true;
      }
      for (var index = 0; index < this.orderItem.length; index++) {
        this.orderItem[index][property] = false;
      }
    },

    inputEvent(value, property, editProperty) {
      console.info("inputEvent");
      console.info(value);
      console.info(property);
      console.info(editProperty);

      if (property == "numberStart" || property == "numberEnd") {
        return true;
      }
      // 这个条件满足 则说明是列编辑  否则是行编辑
      if (this.orderItem[this.editIndex][editProperty]) {
        for (
          var index = this.editIndex + 1;
          index < this.orderItem.length;
          index++
        ) {
          console.info("执行这里");
          this.orderItem[index][property] = value;
        }
      }
      // 行编辑
      else {
        this.editInfo[property] = value;
        console.info(this.editInfo);
      }
    },
    setReplyDate() {
      this.replyDate = null;
      this.showEditDate = true;
    },
    setReplyRequirement2() {
      this.showEditRequirement2 = true;
    },

    saveRequirement2() {
      api
        .updateForRequirement2({
          orderNo: this.orderInfo.orderNo,
          requirement2: this.requirement2,
        })
        .then((res) => {
          this.showEditRequirement2 = false;
          this.orderInfo.requirement2 = this.requirement2;
        });
    },
    saveReplyDate() {
      api
        .updateForPlain({
          orderNo: this.orderInfo.orderNo,
          replyDate: this.replyDate,
        })
        .then((res) => {
          this.showEditDate = false;
          this.orderInfo.replyDate = this.replyDate;
        });
    },
    saveRow(index) {
      console.info(this.editInfo);
      // for (var index = 0; index < this.orderItem.length; index++) {
      //   var item = this.orderItem[index];
      //   console.info("迭代");
      //   console.info(item);
      //   if (item.id == this.editInfo.id) {
      //     console.info("匹配成功");
      //     this.orderItem[index] = this.editInfo;
      //   }
      // }
      this.save();
    },
  },
};
</script>

<style scoped lang="less">
.container {
  font-size: 14px;
  font-weight: 600;
  font-family: Microsoft YaHei !important;
  color: #000;
}
.replyDate {
  width: 130px;
  margin-right: 10px;
}
</style>
